Skip to content

fix(review): linked-issue claim priority theft, unscoped PR-mention pollution, hard-rule stickiness, and draft-cycling double-count - #6455

Merged
JSONbored merged 1 commit into
mainfrom
fix/linked-issue-claim-and-hard-rule-bugs
Jul 16, 2026
Merged

fix(review): linked-issue claim priority theft, unscoped PR-mention pollution, hard-rule stickiness, and draft-cycling double-count#6455
JSONbored merged 1 commit into
mainfrom
fix/linked-issue-claim-and-hard-rule-bugs

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Fixes 4 confirmed adversarial-audit findings in src/db/repositories.ts (with two small, explicitly-scoped cross-file call-site touches to src/queue/processors.ts and src/review/linked-issue-hard-rules.ts — see notes below):

  • Adding/removing a linked-issue reference resets linkedIssueClaimedAt for the WHOLE PR, letting a later PR steal duplicate-winner priority
  • Unscoped PR #N text-mention regex pollutes issue.linkedPrs, hiding fully-available issues from contributor recommendations and marking them do_not_use
  • linkedIssueHardRuleViolatedAt is a permanent, never-cleared marker: disabling a hard rule in repo config does not save a PR it already flagged
  • Repeated-draft-cycling counter has no delivery idempotency — a queue retry of one legitimate draft conversion inflates it to a false "2nd offense" and wrongly closes the PR

Each fix follows the audit's own verified failure scenario and root-cause analysis (2-independent-skeptic adversarial verification pass, both had to vote "confirmed").

Notes on implementation choices:

  • Finding 3's actual bug lives in mergeLinkedIssueHardRuleWithPersistedViolation/resolveLinkedIssueHardRule (src/review/linked-issue-hard-rules.ts), not in repositories.ts itself — the fix threads a new anyRuleOn: boolean parameter rather than inferring intent from live's definedness, since resolveLinkedIssueHardRule collapses "no rule on at all" and "rule on but zero linked issues this pass" to the same undefined return, and only the former should suppress a stale persisted violation.
  • Finding 4's fix threads a deliveryId parameter through bumpPullRequestDraftConversionCount, with a matching one-argument addition at its call site in processors.ts.
  • A related, out-of-scope drift was discovered but not fixed here: packages/loopover-miner/lib/self-review-context.js hand-maintains a JS mirror of extractLinkedPrNumbers that still uses the old unscoped pattern. Flagging for a follow-up issue rather than expanding this PR's blast radius.

Closes #6404
Closes #6410
Closes #6411
Closes #6414

Test plan

  • Regression tests reproducing each audited failure scenario (linked-issue claim overlap, closing-keyword requirement, hard-rule disable rescue, delivery-idempotent draft-conversion counting)
  • npx tsc --noEmit clean, npm run build --workspace @loopover/engine clean
  • Full local gate (npm run test:ci) green

… bugs

- resolveLinkedIssueClaimedAt now only resets the claim timestamp when
  the new linked-issue set has NO overlap with the prior one, instead
  of resetting on any set change. Previously adding an unrelated issue
  reference alongside an already-claimed one reset the whole PR's
  claim time, letting a later PR steal duplicate-cluster winner
  priority for the originally-claimed issue.
- extractLinkedPrNumbers now requires the same closing-keyword
  adjacency (closes/fixes/resolves) extractLinkedIssueNumbersWithOverflow
  already enforces, so a bare "PR #N" text mention in an issue body no
  longer falsely populates linkedPrs and hides an available issue from
  contributor recommendations.
- mergeLinkedIssueHardRuleWithPersistedViolation takes an explicit
  anyRuleOn flag so a persisted hard-rule violation marker is no
  longer resurrected once every linkedIssueHardRule has been disabled
  in config -- previously a PR flagged by a since-disabled rule stayed
  condemned to close forever.
- bumpPullRequestDraftConversionCount is now idempotent per webhook
  deliveryId, mirroring the existing moderation-violation dedup
  pattern, so a queue retry of one legitimate draft conversion no
  longer double-counts toward the repeated-cycling auto-close.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.59%. Comparing base (b09f262) to head (980ec13).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6455   +/-   ##
=======================================
  Coverage   95.59%   95.59%           
=======================================
  Files         589      589           
  Lines       47025    47032    +7     
  Branches    14951    14953    +2     
=======================================
+ Hits        44952    44959    +7     
  Misses       1291     1291           
  Partials      782      782           
Flag Coverage Δ
shard-1 44.07% <41.17%> (-0.19%) ⬇️
shard-2 37.03% <11.76%> (+0.39%) ⬆️
shard-3 32.33% <23.52%> (-0.04%) ⬇️
shard-4 34.47% <64.70%> (-0.83%) ⬇️
shard-5 31.43% <11.76%> (+0.41%) ⬆️
shard-6 45.70% <47.05%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/db/repositories.ts 96.81% <100.00%> (+0.01%) ⬆️
src/queue/processors.ts 95.69% <100.00%> (ø)
src/review/linked-issue-hard-rules.ts 98.24% <100.00%> (+0.03%) ⬆️

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
@JSONbored JSONbored self-assigned this Jul 16, 2026
@JSONbored
JSONbored merged commit 20cba0d into main Jul 16, 2026
17 checks passed
@JSONbored
JSONbored deleted the fix/linked-issue-claim-and-hard-rule-bugs branch July 16, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment